<template>
	<view class="container">
		<view v-if="!yiPinList||yiPinList.length===0"  style="color: #CCCCCC;text-align: center;width: 100%;height: 500upx;line-height: 500upx;font-size: 32upx;"> 暂无数据</view>
		<view v-else>
			<view class="guess-section">
				<view 
					v-for="(item, index) in yiPinList" :key="index"
					class="guess-item"
					@click="navToDetailPage(item)"
				>
					<view class="image-wrapper">
						<image :src="img+item.THUMB" mode="aspectFill"></image>
					</view>
					<view >
						<view style="display: flex;-webkit-justify-content: space-between;justify-content: space-between;">
							<view style="width: 400upx;">
								<text class="title clamp">{{item.NAME}}</text>
							</view>
							<view  >
								<!-- <text class="price">￥{{item.SALEPRICE}}</text> -->
								<text class="price" v-if="!item.MULTIPAY">¥{{item.SALEPRICE}}</text>
								
								<text class="price" v-if="item.MULTIPAY==2&&item.OPPOINT!=0">积分:{{item.OPPOINT}}</text>
								<text class="price" v-if="item.MULTIPAY==2&&item.OPDEDU!=0">抵扣券:{{item.OPDEDU}}</text>
								<text class="price" v-if="item.MULTIPAY==2&&item.OPCOUPON!=0">惠券:{{item.OPCOUPON}}</text>
								
								<text class="price" v-if="item.MULTIPAY==3&&item.MUCHSELLERPRICE!=0">¥{{item.MUCHSELLERPRICE}}</text>
								<text class="price" v-if="item.MULTIPAY==3&&item.MUCHSELLERPRICE!=0&&item.MPPOINT!=0">+</text>
								<text class="price" v-if="item.MULTIPAY==3&&item.MPPOINT!=0">积分:{{item.MPPOINT}}</text>
								<text class="price" v-if="item.MULTIPAY==3&&(item.MUCHSELLERPRICE!=0||item.MPPOINT!=0)&&item.MPDEDU!=0">+</text>
								<text class="price" v-if="item.MULTIPAY==3&&item.MPDEDU!=0">抵扣券:{{item.MPDEDU}}</text>
								<text class="price" v-if="item.MULTIPAY==3&&(item.MUCHSELLERPRICE!=0||item.MPPOINT!=0||item.MPDEDU!=0)&&item.MPCOUPON!=0">+</text>
								<text class="price" v-if="item.MULTIPAY==3&&item.MPCOUPON!=0">惠券:{{item.MPCOUPON}}</text>
							</view>
							
						</view>
						
						<view >
							<text class="tit2 title2 clamp">{{item.SHORTINFO}}</text>
						</view>
					</view>
					
					
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		components: {
		},
		data() {
			return {
				yiPinList: [],
				img:''
			};
		},
		async onLoad() {
			this.loadData();
			this.img = getApp().globalData.imageAddress;
			uni.startPullDownRefresh();
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {  
			async loadData() {
					//加载信息
				this.$http.post("/goods/fresh",{
					SIGNATURE : uni.getStorageSync("SIGNATURE"),
					GP: '5'
				}).then((e)=>{
					e.data.OBJECT.map(item=>{
						if(item.ID){
							this.yiPinList.push(item)
						}
					})
					
				}).catch((err)=>{
					console.log("请求超时",err);
				})
			},
			//跳转商品详情页
			navToDetailPage(item) {
				if(item.MULTIPAY){
					let ids=item.GOODID;
					let sid=item.ID;
					uni.navigateTo({
						url: `/pages/product/productExchange?id=${ids}&sid=${sid}`
					})
				}else{
					let id = item.ID;
					uni.navigateTo({
						url: `/pages/product/product?id=${id}`
					})
				}
			}
		},
	}
</script>

<style lang="scss">
	page{
		background-color: #F5F5F5;
		padding: 0upx 20upx;
	}
	.un-top{
		width: 100%;
		height: 360upx;
		background: #fff;
		image{
			width:100%;
			height: 100%; 
		}
	}
	.guess-section{
		display:flex;
		flex-wrap:wrap;
		.guess-item{
			background: #fff;
			margin-bottom: 20upx;
			flex-direction: column;
			width: 100%;
			padding: 30upx 20upx 30upx;
			
		}
		.image-wrapper{
			width: 100%;
			height: 335upx;
			border-radius: 5px;
			overflow: hidden;
			image{
				width: 100%;
				height: 100%;
				opacity: 1;
			}
		}
		.title{
			text-align: left;
			font-size: $font-sm+3upx;
			color: $font-color-dark;
			line-height: 60upx;
		}
		.price{
			float: right;
			font-size: $font-sm+3upx;
			color: $uni-color-primary;
			line-height: 1;
			line-height: 50upx;
		}
		.tit2{
			font-size: $font-sm;
			color: $font-color-light;
			line-height: 30upx;
			text-align: left;
			
		}
	}
</style>
